package com.andy.web.gotopage;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.andy.domain.result.BaseResult;
import com.andy.web.util.SessionUtil;

@RestController
@RequestMapping("/")
public class GoToPageController {
	
	@RequestMapping("/index")
	public ModelAndView index() {
		ModelAndView mv = new ModelAndView("index");
		mv.addObject("user", SessionUtil.getCurrentUser());
		return mv;
	}
	
	@RequestMapping("/tools")
	public ModelAndView tools() {
		ModelAndView mv = new ModelAndView("tools");
		mv.addObject("user", SessionUtil.getCurrentUser());
		return mv;
	}
	
	@RequestMapping("/tools/json")
	public ModelAndView toolsJson() {
		ModelAndView mv = new ModelAndView("tools/json");
		mv.addObject("user", SessionUtil.getCurrentUser());
		return mv;
	}
	
	@RequestMapping("/tools/generatefileurl")
	public ModelAndView generatefileurl() {
		ModelAndView mv = new ModelAndView("tools/generatefileurl");
		mv.addObject("user", SessionUtil.getCurrentUser());
		return mv;
	}
	
	@RequestMapping("/register")
	public ModelAndView register() {
		return new ModelAndView("/user/register");
	}
	
	@RequestMapping("/login")
	public ModelAndView login() {
		return new ModelAndView("/user/login");
	}
	
	@RequestMapping("/logout")
	public ModelAndView logout() {
		SessionUtil.invalidate();
		return new ModelAndView("index");
	}
}
